using System;
using System.Collections.Generic;
using System.Text;
using PH.Mission;
using System.Drawing;

namespace Hoshimi
{
	public class NavPointContainer
	{
		protected NavPoint mNavPoint = null;

		public NavPoint myNavPoint { get { return this.mNavPoint; } }

		protected ExplorerBot mExplorerBot = null;

		public bool Reached		{ get { return this.mNavPoint.Reached;		} }
		public Point Location	{ get { return this.mNavPoint.Location;		} }
		public int EndTurn		{ get { return this.mNavPoint.EndTurn;		} }
		public int StartTurn	{ get { return this.mNavPoint.StartTurn;	} }
		public int Stock		{ get { return this.mNavPoint.Stock;		} }

		public void Take(ExplorerBot bot)
		{
			this.mExplorerBot = bot;
		}

		public bool IsTaken()
		{
			if (this.mExplorerBot == null)
			{
				return false;
			}

			if (this.mExplorerBot.ObjectivePoint == null)
			{
				return false;
			}

			return (this.mExplorerBot.ObjectivePoint.IsSameNavPoint(this));
		}

		public bool Release(ExplorerBot bot)
		{
			if (this.mExplorerBot != bot)
			{
				return false;
			}

			this.mExplorerBot = null;

			return true;
		}

		public bool IsAZNNeeded()
		{
			return (this.Stock > 0);
		}

		public bool IsSameNavPoint(NavPointContainer navPointContainer)
		{
			return (navPointContainer.mNavPoint == this.mNavPoint);
		}

		public NavPointContainer(NavPoint navPoint)
		{
			this.mNavPoint = navPoint;
		}

		public override bool Equals(object obj)
		{
			if (obj == null) return false;

			if (this.GetType() != obj.GetType()) return false;

			// safe because of the GetType check
			NavPointContainer cust = (NavPointContainer)obj;

			return (cust.Location == this.Location);
		}

		public override int GetHashCode()
		{
			return base.GetHashCode();
		}
	}
}
